package com.lmabbe.core.common.converter;

import com.lmabbe.core.common.dto.SysUserRoleDTO;
import com.lmabbe.core.common.entitys.SysUserRole;
import com.lmabbe.core.common.vo.SysUserRoleVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * 用户-权限表 转换器
 *
 * @author lmabbe
 */
@Mapper(componentModel = "spring")
public interface SysUserRoleConverter {

    /**
     * dto转实体
     *
     * @param to
     * @return
     */
    SysUserRole dto2Entity(SysUserRoleDTO to);

    /**
     * dto转实体
     *
     * @param to
     * @return
     */
    @Mapping(target = "userRoleId", source = "userRoleId")
    SysUserRole dto2Entity(SysUserRoleDTO to, Long userRoleId);

    /**
     * 数据列表转Vo列表
     *
     * @param list
     * @return
     */
    List<SysUserRoleVO> list2Vos(List<SysUserRole> list);

    /**
     * 实体转VO
     *
     * @param entity
     * @return
     */
    SysUserRoleVO entity2Vo(SysUserRole entity);
}